﻿@model IQueryable<MalkiSumWeb.Models.File>
@{
    ViewBag.Title = "FieldView";
    Layout = null;
}
@*@if (memberAct.ActionDateTime.HasValue) { <text> @memberAct.ActionDateTime.Value.ToString("dd-MM-yyyy"); </text>}*@
@if (Model != null)
{
    var lst = Model.Take(8).ToList();
    int round = lst.Count % 4 == 0 ? (lst.Count / 4) - 1 : lst.Count / 4;
    if (lst.Count > 0)
    {
    <text>
    <div class="row content">
        <div class="col-lg-12">
            <legend class="categoryHeader">
                <h4>
                    @lst[0].Field.NameEn</h4>
            </legend>
            <div id="@Url.Content("carousel-top10" + lst[0].ID)" class="carousel slide">
                <!-- Wrapper for slides -->
                <div class="carousel-inner">
                    @for (int i = 0; i <= round; i++)
                    {
                        if (i == 0)
                        {
                        <div class="item active">
                            @for (int y = 0; y < lst.Count; y++)
                            {
                                if (y / 4 == i)
                                {

                                    
                                    
                                    
                                    
                                <div class="col-lg-3 article">
                                    <h5>
                                        @lst[y].Name</h5>
                                    <img src="@Url.Content("~/Content/images/logo_placeHolder.png")"/>
                                    <h3>
                                        Why Sass?</h3>
                                    <p>
                                        I was a reluctant believer in Sass. I write stylesheets by hand!</p>
                                    <div class="popMenu">
                                        <ul>
                                            <li><a href="javascript:void(0);" title="Like"><i class="fa fa-heart"></i></a></li>
                                            <li><a href="javascript:void(0);" title="Share"><i class="fa fa-share"></i></a></li>
                                            <li><a href='@Url.Content("~/files/download?id=" + lst[y].ID)' title="Download"><i
                                                class="fa fa-download"></i></a></li>
                                        </ul>
                                    </div>
                                    <div class="info">
                                        <span>
                                            @if (Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalDays) / 30 > 0)
                                            {
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalDays) / 30) <text>
                                                Month </text>
                                                
                                             
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalDays) % 30) <text>
                                                Days </text>
                                            }
                                            else if (Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalHours) / 24 > 0)
                                            {
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalHours) / 24) <text>
                                                Days </text>
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalHours % 24)) <text>
                                                Hours </text>
                                            }
                                            else if (Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalMinutes) / 60 > 0)
                                            {
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalMinutes) / 60) <text>
                                                Hours </text>
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalMinutes % 60)) <text>
                                                Minutes </text>
                                            }
                                            else if (Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalSeconds) / 60 > 0)
                                            {
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalSeconds) / 60) <text>
                                                Minutes </text>
                                                              
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalSeconds) % 60) <text>
                                                Seconds </text>                                 
                                                
                                            }
                                            ago.
                                        </span>
                                        <br /> 
                                        <span><i class="fa fa-eye"></i> Views @lst[y].ViewCount
                                        </span><a href="javascript:void(0);">Read <i class="fa fa-chevron-right"></i></a>
                                    </div>
                                </div>
                                
                                
                                
                                
                                }
                            }
                        </div>
                        }
                        else
                        {
                        <div class="item">
                            @for (int y = 0; y < lst.Count; y++)
                            {
                                if (y / 4 == i)
                                {
                                    
                                    
                                          
                                <div class="col-lg-3 article">
                                    <h5>
                                        @lst[y].Name</h5>
                                    <img src="@Url.Content("~/Content/images/logo_placeHolder.png")"/>
                                    <h3>
                                        Why Sass?</h3>
                                    <p>
                                        I was a reluctant believer in Sass. I write stylesheets by hand!</p>
                                    <div class="popMenu">
                                        <ul>
                                            <li><a href="javascript:void(0);" title="Like"><i class="fa fa-heart"></i></a></li>
                                            <li><a href="javascript:void(0);" title="Share"><i class="fa fa-share"></i></a></li>
                                            <li><a href='@Url.Content("~/files/download?id=" + lst[y].ID)' title="Download"><i
                                                class="fa fa-download"></i></a></li>
                                        </ul>
                                    </div>
                                    <div class="info">
                                        <span>
                                            @if (Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalDays) / 30 > 0)
                                            {
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalDays) / 30) <text>
                                                Month </text>
                                                
                                             
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalDays) % 30) <text>
                                                Days </text>
                                            }
                                            else if (Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalHours) / 24 > 0)
                                            {
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalHours) / 24) <text>
                                                Days </text>
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalHours % 24)) <text>
                                                Hours </text>
                                            }
                                            else if (Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalMinutes) / 60 > 0)
                                            {
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalMinutes) / 60) <text>
                                                Hours </text>
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalMinutes % 60)) <text>
                                                Minutes </text>
                                            }
                                            else if (Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalSeconds) / 60 > 0)
                                            {
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalSeconds) / 60) <text>
                                                Minutes </text>
                                                              
                                                @(Convert.ToInt64(DateTime.Now.Subtract(lst[y].PostDate.Value).TotalSeconds) % 60) <text>
                                                Seconds </text>                                 
                                                
                                            }
                                            ago.
                                        </span>
                                        <br />
                                         <span><i class="fa fa-eye"></i> Views
                                            @lst[y].ViewCount</span> <a href="javascript:void(0);">Read <i class="fa fa-chevron-right">
                                            </i></a>
                                    </div>
                                </div>
                                
                                

                                }
                            }
                        </div>
                        }




                    }
                </div>
                <!-- Controls -->
                <a class="left carousel-control" href="@Url.Content("#carousel-top10" + lst[0].ID)" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left"></span></a><a class="right carousel-control" href="@Url.Content("#carousel-top10" + lst[0].ID)" data-slide="next">
                        <span class="glyphicon glyphicon-chevron-right"></span></a>
            </div>
        </div>
    </div>
    </text>
    }

}